package com.leetroll.common.vo;

import com.leetroll.common.entity.Item;
import lombok.Data;

import java.util.List;

@Data
public class ItemVO extends BaseVO {
    //所属分类id
    private Long catId;
    //名称
    private String name;
    //描述
    private String desp;
    //类型
    private String type;
    //价格
    private Double price;
    //作者
    private String author;
    //状态
    private String status;
    private String mark;
    private String tag;

    //下载/学习数量
    private Integer downCnt;
    private Integer likeCnt;
    private Integer collectCnt;

    private Boolean liked = false;
    private Boolean collected = false;
    private Boolean bought = false;
    private String platform;

    //主图
    private FileVO main;
    //预览图
    private List<FileVO> previews;
    //下载附件
    private List<FileVO> attachments;
    //章节信息
    private List<ChapterVO> chapters;

    public static ItemVO fromItem(Item item) {
        ItemVO itemVO = new ItemVO();
        itemVO.setId(item.getId());
        itemVO.name = item.getName();
        itemVO.desp = item.getDesp();
        itemVO.type = item.getType();
        itemVO.mark = item.getMark();
        itemVO.price = item.getPrice();
        itemVO.author = item.getAuthor();
        itemVO.status = item.getStatus();
        itemVO.tag = item.getTag();
        itemVO.catId = item.getCatId();
        itemVO.platform = item.getPlatform();
        return itemVO;
    }
}
